package com.joyintech.feign;

import feign.RequestInterceptor;
import feign.RequestTemplate;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.MDC;

public class FeignRequestInterceptor implements RequestInterceptor {
    @Override
    public void apply(RequestTemplate template) {
        String  traceId = MDC.get("traceId");
        if(StringUtils.isNotBlank(traceId)){
            template.header("X-Trace-Id",traceId);
        }
    }
}
